package xcheck

import "gitee.com/shuohe/xutils/xerror"

type IntChecker func(value int) error
type StringChecker func(value string) error

func GreaterThan(max int) IntChecker {
	return func(value int) error {
		if value <= max {
			return xerror.SimpleNewf("xcheck.GreaterThan(%v): Failed due to value %v.", max, value)
		}
		return nil
	}
}

func GreaterEqualThan(max int) IntChecker {
	return func(value int) error {
		if value < max {
			return xerror.SimpleNewf("xcheck.GreaterEqualThan(%v): Failed due to value %v.", max, value)
		}
		return nil
	}
}

func NotEmpty(value string) error {
	if value == "" {
		return xerror.New("Failed due to empty string value.")
	}
	return nil
}
